package com.gmail.hh.flickrj.sample.android.fragments;


import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.widget.ImageButton;

import com.gmail.hh.flickrj.sample.android.FlickrjMainActivity;
import com.gmail.hh.flickrj.sample.android.R;
import com.gmail.hh.flickrj.sample.android.data.DataManagerFlickr;
import com.gmail.hh.flickrj.sample.android.interfaces.IPhotoSelectedListener;


@SuppressLint("NewApi")
public class FragmentDetail1 extends Fragment  {

	public static final String TAG = "fragment_detail1";

	private ImageButton resetAuthButton;
	
	// each Activity which uses this Fragment must implement this interface
	private FlickrjMainActivity mActivity;
	
	
	@Override
    public void onAttach(Activity activity) {
        super.onAttach(activity);
        // This makes sure that the container activity has implemented
        // the callback interface. If not, it throws an exception
        try {
        	mActivity = (FlickrjMainActivity) activity;
        } catch (ClassCastException e) {
            throw new ClassCastException(activity.toString()
                    + " must be the flickr... activity xxxxxxxxxxx");
        }
	}
	@Override
	public void onCreate(Bundle arg0) {

		super.onCreate(arg0);
		setRetainInstance(true);
	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup vg, Bundle data) {
		// Inflate the  layout file.
		View view = inflater.inflate(R.layout.fragment_detail1, null);

		this.resetAuthButton = (ImageButton) view.findViewById(R.id.btnResetAuth);

	    // reload of photos also when button clicked
		this.resetAuthButton.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				// reset Auth
				DataManagerFlickr.getInstance().saveOAuthToken(null, null, null, null);
			}
		});
		return view;
	}

	@Override
	public void onViewCreated(View arg0, Bundle arg1) {
		super.onViewCreated(arg0, arg1);

	}




}
